home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / bin / zdiff < prev    next >
Encoding:
Text File  |  2007-01-16  |  2.4 KB  |  82 lines

  1. #!/bin/sh
  2. # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
  3.  
  4. # Zcmp and zdiff are used to invoke the cmp or the  diff  pro-
  5. # gram  on compressed files.  All options specified are passed
  6. # directly to cmp or diff.  If only 1 file is specified,  then
  7. # the  files  compared  are file1 and an uncompressed file1.gz.
  8. # If two files are specified, then they are  uncompressed  (if
  9. # necessary) and fed to cmp or diff.  The exit status from cmp
  10. # or diff is preserved.
  11.  
  12. PATH="/usr/bin:$PATH"; export PATH
  13. case "$0" in
  14.   *cmp) prog=cmp ; comp=${CMP-cmp}   ;;
  15.   *)    prog=diff; comp=${DIFF-diff} ;;
  16. esac
  17.  
  18. version="z$prog (gzip) 1.3.9
  19. Copyright (C) 2006 Free Software Foundation, Inc.
  20. This is free software.  You may redistribute copies of it under the terms of
  21. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  22. There is NO WARRANTY, to the extent permitted by law.
  23.  
  24. Written by Jean-loup Gailly."
  25.  
  26. usage="Usage: z$prog [OPTION]... FILE1 [FILE2]
  27. Compare FILE1 to FILE2, using their uncompressed contents if they are
  28. compressed.  If FILE2 is omitted, compare FILE1 to the uncompressed
  29. contents of FILE1.gz.  Do comparisons like '$prog' does.
  30.  
  31. OPTIONs are the same as for '$prog'.
  32.  
  33. Report bugs to <bug-gzip@gnu.org>."
  34.  
  35. OPTIONS=
  36. FILES=
  37. while :; do
  38.   case $1 in
  39.   --h*) echo "$usage" || exit 2; exit;;
  40.   --v*) echo "$version" || exit 2; exit;;
  41.   --) shift; break;;
  42.   -*) OPTIONS="$OPTIONS $ARG"; shift;;
  43.   esac
  44. done
  45. for file; do
  46.   test -f "$file" || {
  47.     echo "$prog: $file not found or not a regular file"
  48.     exit 2
  49.   }
  50. done
  51. if test $# -eq 1; then
  52.     FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'`
  53.     gzip -cd -- "$1" | $comp $OPTIONS - "$FILE"
  54.  
  55. elif test $# -eq 2; then
  56.     case "$1" in
  57.         *[-.]gz* | *[-.][zZ] | *.t[ga]z)
  58.                 case "$2" in
  59.             *[-.]gz* | *[-.][zZ] | *.t[ga]z)
  60.             F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
  61.             set -C
  62.             trap 'rm -f /tmp/"$F".$$; exit 2' HUP INT PIPE TERM 0
  63.             gzip -cdfq -- "$2" > /tmp/"$F".$$ || exit
  64.             gzip -cdfq -- "$1" | $comp $OPTIONS - /tmp/"$F".$$
  65.                         STAT="$?"
  66.             /bin/rm -f /tmp/"$F".$$ || STAT=2
  67.             trap - HUP INT PIPE TERM 0
  68.             exit $STAT;;
  69.  
  70.         *)      gzip -cdfq -- "$1" | $comp $OPTIONS - "$2";;
  71.                 esac;;
  72.         *)      case "$2" in
  73.             *[-.]gz* | *[-.][zZ] | *.t[ga]z)
  74.             gzip -cdfq -- "$2" | $comp $OPTIONS "$1" -;;
  75.                 *)      $comp $OPTIONS "$1" "$2";;
  76.                 esac;;
  77.     esac
  78. else
  79.     echo "$usage"
  80.     exit 2
  81. fi
  82.